package com.test;


//import com.tencent.sr.rmall.springbootstarter.route.TsfTagUtils;

import java.io.Serializable;
import java.util.Map;


/**
 * Copyright
 *
 * @Author WuHuang
 * @Date 2023/3/31
 */

public class KafkaMetaMessage implements Serializable {

    private static final long serialVersionUID = -853328718587677983L;
    /**
     * 服务器IP
     */
    private String senderIp;
    /**
     * 时间戳
     */
    private Long timestamp;
    /**
     * 链路跟踪ID
     */
    private String traceId;
    /**
     * 应用名
     */
    private String appName;
    /**
     * 应用参数
     */
    private Map<String, Object> tags;

    /**
     * 系统tag参数,仅供路由使用,业务请勿使用
     */
    private Map<String, Object> tsfTags;

    /**
     * 消息体
     */
    private Object data;


    private boolean needInject = false;

    private boolean needLogRequestId = false;

    public String getSenderIp() {
        return senderIp;
    }

    public void setSenderIp(String senderIp) {
        this.senderIp = senderIp;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public Map<String, Object> getTags() {
        return tags;
    }

    public void setTags(Map<String, Object> tags) {
        this.tags = tags;
    }

//    public Object getData() {
//        if (needInject) {
//            TsfTagUtils.injectContextTag(this);
//            needInject = false;
//        }
//        if (needLogRequestId) {
//            TsfTagUtils.logRequestId(this);
//        }
//        return data;
//    }

    public void setData(Object data) {
        this.data = data;
    }

//    public KafkaMetaMessage() {
//        TsfTagUtils.initBaseInfo(this);
//    }


    /**
     * 业务请勿使用, 请用getTags做业务参数传递
     */
    @Deprecated
    public Map<String, Object> getTsfTags() {
        return tsfTags;
    }

    /**
     * 业务请勿使用, 请用setTags做业务参数传递
     */
    @Deprecated
    public void setTsfTags(Map<String, Object> tsfTags) {
        this.tsfTags = tsfTags;
        needInject = true;
        needLogRequestId = true;
    }


    /**
     * 业务请勿使用, 业务请用getData
     */
    @Deprecated
    public Object obtainData() {
        return data;
    }


    /**
     * 业务请勿使用, 请用setTags做业务参数传递
     */
    @Deprecated
    public Map<String, Object> obtainTsfTags() {
        return tsfTags;
    }


    /**
     * 业务请勿使用, 请用setTags做业务参数传递
     */
    @Deprecated
    public void putUseTsfTags(Map<String, Object> tsfTags) {
        this.tsfTags = tsfTags;
    }

    @Deprecated
    public void putNeedLogRequestId(boolean needLogRequestId) {
        this.needLogRequestId = needLogRequestId;
    }

}
